if (tx->response_headers != NULL) {
htp_header_t *h_content_type = htp_table_get_c(tx->response_headers, "content-type");
if (h_content_type != NULL) {
- const size_t size = bstr_len(h_content_type->value) * 2 + 1;
- char string[size];
- BytesToStringBuffer(bstr_ptr(h_content_type->value), bstr_len(h_content_type->value), string, size);
- char *p = strchr(string, ';');
+ uint32_t len = (uint32_t)bstr_len(h_content_type->value);
+ const uint8_t *p = memchr(bstr_ptr(h_content_type->value), ';', len);
if (p != NULL)
- *p = '\0';
- jb_set_string(js, "http_content_type", string);
+ len = (uint32_t)(p - bstr_ptr(h_content_type->value));
+ jb_set_string_from_bytes(
+ js, "http_content_type", bstr_ptr(h_content_type->value), len);
}
htp_header_t *h_content_range = htp_table_get_c(tx->response_headers, "content-range");
if (h_content_range != NULL) {